home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / prog / mui / muibuilder / mb / m2 / m2mui / mbmuiclasses.def next >
Text File  |  1994-11-30  |  14KB  |  392 lines

  1. DEFINITION MODULE MuiClasses;
  2.  
  3. (*************************************************************************
  4. ** Structures and Macros for creating MUI custom classes.
  5. **
  6. ** converted for M2 by Christian 'Kochtopf' Scholz
  7. ||
  8. || some changes by Stefan Schulz / 20.09.94
  9. ||
  10. **
  11. **************************************************************************
  12. **
  13. ** $Id: MuiClasses.def 1.8 1994/08/16 20:24:55 Kochtopf Exp $
  14. **
  15. ** $Log: MuiClasses.def $
  16. # Revision 1.8  1994/08/16  20:24:55  Kochtopf
  17. # mCustumClassPtr hinzugefügt
  18. # mCustomClass nach M2-Standard umbenannt
  19. #
  20. # Revision 1.7  1994/08/16  19:41:22  Kochtopf
  21. # added MUIKEYPOPUP
  22. #
  23. # Revision 1.6  1994/06/30  21:03:01  Kochtopf
  24. # changed again SHORTINT to SHORTCARD for madAddLeft, etc.
  25. #
  26. # Revision 1.5  1994/06/30  20:56:40  Kochtopf
  27. # Typ bei madAddLeft, etc. von BYTE in SHORTINT geändert, um
  28. # besser damit rechnen zu können.
  29. #
  30. # Revision 1.4  1994/06/27  22:04:58  Kochtopf
  31. # changed name from MUIClasses to MuiClasses
  32. # added definition of mCustomClass
  33. #
  34. # Revision 1.3  1994/06/23  21:36:53  Kochtopf
  35. # upgraded to MUI 2.1
  36. # added mCustumClass-Definition
  37. #
  38. # Revision 1.2  1994/02/19  12:42:19  Kochtopf
  39. # Neue Prozeduren hinzugefuegt, die in mui.h definiert waren.
  40. # Ausserdem etwas die Reihenfolge geaendert, so dass man jetzt alles
  41. # benutzen koennen sollte.
  42. #
  43. # Revision 1.1  1994/02/02  09:37:18  Kochtopf
  44. # Initial revision
  45. #
  46. **
  47. **************************************************************************)
  48.  
  49. FROM    SYSTEM      IMPORT ADDRESS, WORD, BYTE, LONGSET;
  50. FROM    IntuitionD  IMPORT ObjectPtr, WindowPtr, ScreenPtr, DrawInfoPtr, IBox,
  51.                            IntuiMessagePtr, IClassPtr;
  52. FROM    ExecD       IMPORT LibraryPtr;
  53. FROM    GraphicsD   IMPORT TextFontPtr, RastPortPtr;
  54. FROM    MuiD        IMPORT APTR;
  55.  
  56. (*
  57. ** at the beginning some general things used for BOOPSI-Objects
  58. *)
  59.  
  60. (* get a pointer to our instance data *)
  61.  
  62. PROCEDURE InstData(cl : IClassPtr; obj : ObjectPtr) : ADDRESS;
  63.  
  64. (* get the size ... *)
  65.  
  66. PROCEDURE InstSize(cl : IClassPtr) : CARDINAL;
  67.  
  68.  
  69. (*
  70. ** now the things concerning MUI's view of the things
  71. **
  72. ** GENERAL NOTES:
  73. **
  74. ** - Everything described in this defintion file is only valid within
  75. **   MUI classes. You may never use any of these things out of
  76. **   a class, e.g. in a traditional MUI application.
  77. **
  78. ** - Except when otherwise stated, all structures are strictly read only.
  79. *)
  80.  
  81. (* Pointer-Types *)
  82.  
  83. TYPE mGlobalInfoPtr     = POINTER TO mGlobalInfo;
  84.      mMinMaxPtr         = POINTER TO mMinMax;
  85.      mNotifyDataPtr     = POINTER TO mNotifyData;
  86.      mAreaDataPtr       = POINTER TO mAreaData;
  87.      mRenderInfoPtr     = POINTER TO mRenderInfo;
  88.      mConfigurationPtr  = ADDRESS;
  89.      mImagePtr          = ADDRESS;
  90.      mImageInfoPtr      = ADDRESS;
  91.      WORDPtr            = POINTER TO WORD;
  92.      mCustomClassPtr    = POINTER TO mCustomClass;
  93.  
  94.  
  95. (* 
  96. ** Definitions for madFlags 
  97. ** (you will get these flags e.g. with a Draw-Method.)
  98. *)
  99.  
  100. TYPE  MADFlags = (drawObject, (* completely redraw yourself *)
  101.                   drawUpdate, (* only update! *)
  102.                   p2, p3, p4, p5, p6, p7, p8, p9, p10, p11,
  103.                   p12, p13, p14, p15, p16, p17, p18, p19, p20, p21,
  104.                   p22, p23, p24, p25, p26, p27, p28, p29, p30, p31
  105.                   (* rest is private, but must be specified to get a LONGSET *)
  106.                  );
  107.  
  108.       MADFlagSet = SET OF MADFlags;
  109.  
  110.  
  111. (* 
  112. ** Type definitions of some important Methods
  113. ** You will need them in your own classes.
  114. *)
  115.  
  116. (* Area *)
  117.  
  118. TYPE    mpAskMinMaxPtr  = POINTER TO mpAskMinMax;
  119.         mpDrawPtr       = POINTER TO mpDraw;
  120.         mpHandleInputPtr= POINTER TO mpHandleInput;
  121.         mpSetUpPtr      = POINTER TO mpSetUp;
  122.         mpBoopsiQueryPtr= POINTER TO mpBoopsiQuery;
  123.  
  124. TYPE    mpAskMinMax     = RECORD
  125.                             id          : LONGINT;
  126.                             MinMaxInfo  : mMinMaxPtr;
  127.                           END;
  128.  
  129.         mpDraw          = RECORD
  130.                             id          : LONGINT;
  131.                             flags       : MADFlagSet;
  132.                           END;
  133.  
  134.         mpHandleInput   = RECORD
  135.                             id          : LONGINT;
  136.                             imsg        : IntuiMessagePtr;
  137.                             muikey      : LONGINT;
  138.                           END;
  139.  
  140.         mpSetUp         = RECORD
  141.                             id          : LONGINT;
  142.                             RenderInfo  : mRenderInfoPtr;
  143.                           END;
  144.  
  145.         mpBoopsiQuery   = RECORD
  146.                             id          : LONGCARD;
  147.                             screen      : ScreenPtr;      (* obsolete   *)
  148.                             flags       : LONGCARD;       (* read only  *)
  149.                             minWidth,                     (* write only *)
  150.                             minHeight,                    (* write only *)
  151.                             maxWidth,                     (* write only *)
  152.                             maxHeight,                    (* write only *)
  153.                             defWidth,                     (* write only *)
  154.                             defHeight   : LONGCARD;       (* write only *)
  155.                             renderInfo  : mRenderInfoPtr; (* read only  *)
  156.                             
  157.                             (* may grow in future ... *)
  158.                           END;
  159.  
  160. CONST   mbqfHORIZ    = 1;
  161. CONST   mbqMAXMAX    = 10000;
  162.  
  163.  
  164. (* (partial) instance data of notify class *)
  165.  
  166. TYPE mNotifyData = RECORD
  167.         globalInfo       : mGlobalInfoPtr;
  168.         userData         : LONGINT;
  169.         priv0               : LONGINT;
  170.         priv1               : LONGINT;
  171.         priv2               : LONGINT;
  172.         priv3               : LONGINT;
  173.         priv4               : LONGINT;
  174.     END;
  175.  
  176.  
  177. (* mMinMax structure holds information about minimum, maximum
  178.    and default dimensions of an object. *)
  179.  
  180.      mMinMax = RECORD
  181.                 MinWidth   : CARDINAL;
  182.                 MinHeight  : CARDINAL;
  183.                 MaxWidth   : CARDINAL;
  184.                 MaxHeight  : CARDINAL;
  185.                 DefWidth   : CARDINAL;
  186.                 DefHeight  : CARDINAL;
  187.         END;
  188.  
  189. CONST mMAXMAX = 10000; (* use this if a dimension is not limited. *)
  190.  
  191.  
  192. (* (partial) instance data of area class *)
  193.  
  194. TYPE mAreaData = RECORD
  195.                 renderInfo       : mRenderInfoPtr;     (* RenderInfo for this object *)
  196.                 background       : mImagePtr;          (* Background Image *)
  197.                 font             : TextFontPtr;          (* Font *)
  198.                 minMax           : mMinMax;              (* min/max/default sizes *)
  199.                 box              : IBox;                 (* position and dimension *)
  200.  
  201.                 addLeft          : SHORTCARD;            (* frame & innerspacing left offset *)
  202.                 addTop           : SHORTCARD;            (* frame & innerspacing top offset *)
  203.                 subWidth         : SHORTCARD;            (* frame & innerspacing add. width *)
  204.                 subHeight        : SHORTCARD;            (* frame & innerspacing add. height *)
  205.  
  206.                 flags            : MADFlagSet;           (* see definitions above *)
  207.  
  208.                 (* ... private data follows ... *)
  209.         END;
  210.  
  211.  
  212.  
  213. (* Global information about configuration and parent application. *)
  214.  
  215. TYPE mGlobalInfo = RECORD
  216.                         configuration            : mConfigurationPtr;
  217.                         applicationObject        : ObjectPtr;
  218.                         (* ... private data follows ... *)
  219.                      END;
  220.  
  221. (* MUI's draw pens *)
  222.  
  223. CONST MPENSHINE      =0;
  224. CONST MPENHALFSHINE  =1;
  225. CONST MPENBACKGROUND =2;
  226. CONST MPENHALFSHADOW =3;
  227. CONST MPENSHADOW     =4;
  228. CONST MPENTEXT       =5;
  229. CONST MPENFILL       =6;
  230. CONST MPENCOUNT      =7;
  231.  
  232.  
  233. (* Information on display environment *)
  234.  
  235. TYPE mRenderInfo = RECORD
  236.                             windowObject        : ObjectPtr;     (* valid between MUIMSetup/MUIMCleanup *)
  237.  
  238.                             screen              : ScreenPtr;     (* valid between MUIMSetup/MUIMCleanup *)
  239.                             drawInfo            : DrawInfoPtr;   (* valid between MUIMSetup/MUIMCleanup *)
  240.                             pens                : WORDPtr;       (* valid between MUIMSetup/MUIMCleanup *)
  241.                             window              : WindowPtr;     (* valid between MUIMShow/MUIMHide *)
  242.                             rastPort            : RastPortPtr;   (* valid between MUIMShow/MUIMHide *)
  243.  
  244.                         (* ... private data follows ... *)
  245.                      END;
  246.     
  247.  
  248. (*
  249. ** some procedures to get some information about our object 
  250. *)
  251.  
  252. PROCEDURE muiNotifyData(obj : APTR) : mNotifyDataPtr;
  253. PROCEDURE muiAreaData(obj : APTR) : mAreaDataPtr;
  254. PROCEDURE muiGlobalInfo(obj : APTR) : mGlobalInfoPtr;
  255. PROCEDURE muiRenderInfo(obj : APTR) : mRenderInfoPtr;
  256. PROCEDURE muiUserData(obj : APTR) : LONGINT;
  257.  
  258.  
  259. (*
  260. ** some more specialized functions to retain information about special
  261. ** object-data like rastport, window, etc.
  262. *)
  263.  
  264. PROCEDURE OBJ_app(obj : APTR) : ObjectPtr;
  265. PROCEDURE OBJ_win(obj : APTR) : ObjectPtr;
  266. PROCEDURE OBJ_dri(obj : APTR) : DrawInfoPtr;
  267. PROCEDURE OBJ_window(obj : APTR) : WindowPtr;
  268. PROCEDURE OBJ_screen(obj : APTR) : ScreenPtr;
  269. PROCEDURE OBJ_rp(obj : APTR) : RastPortPtr;
  270. PROCEDURE OBJ_left(obj : APTR) : INTEGER;
  271. PROCEDURE OBJ_top(obj : APTR) : INTEGER;
  272. PROCEDURE OBJ_width(obj : APTR) : INTEGER;
  273. PROCEDURE OBJ_height(obj : APTR) : INTEGER;
  274. PROCEDURE OBJ_right(obj : APTR) : INTEGER;
  275. PROCEDURE OBJ_bottom(obj : APTR) : INTEGER;
  276. PROCEDURE OBJ_addleft(obj : APTR) : INTEGER;
  277. PROCEDURE OBJ_addtop(obj : APTR) : INTEGER;
  278. PROCEDURE OBJ_subwidth(obj : APTR) : INTEGER;
  279. PROCEDURE OBJ_subheight(obj : APTR) : INTEGER;
  280. PROCEDURE OBJ_mleft(obj : APTR) : INTEGER;
  281. PROCEDURE OBJ_mtop(obj : APTR) : INTEGER;
  282. PROCEDURE OBJ_mwidth(obj : APTR) : INTEGER;
  283. PROCEDURE OBJ_mheight(obj : APTR) : INTEGER;
  284. PROCEDURE OBJ_mright(obj : APTR) : INTEGER;
  285. PROCEDURE OBJ_mbottom(obj : APTR) : INTEGER;
  286. PROCEDURE OBJ_font(obj : APTR) : TextFontPtr;
  287. PROCEDURE OBJ_flags(obj : APTR) : MADFlagSet;
  288.  
  289.    
  290. (* User configurable keyboard events coming with MUIMHandleInput *)
  291.  
  292. CONST MUIKEYRELEASE     = -2; (* not a real key, faked when MUIKEYPRESS is released *)
  293. CONST MUIKEYNONE        = -1;
  294. CONST MUIKEYPRESS       =  0;
  295. CONST MUIKEYTOGGLE      =  1;
  296. CONST MUIKEYUP          =  2;
  297. CONST MUIKEYDOWN        =  3;
  298. CONST MUIKEYPAGEUP      =  4;
  299. CONST MUIKEYPAGEDOWN    =  5;
  300. CONST MUIKEYTOP         =  6;
  301. CONST MUIKEYBOTTOM      =  7;
  302. CONST MUIKEYLEFT        =  8;
  303. CONST MUIKEYRIGHT       =  9;
  304. CONST MUIKEYWORDLEFT    = 10;
  305. CONST MUIKEYWORDRIGHT   = 11;
  306. CONST MUIKEYLINESTART   = 12;
  307. CONST MUIKEYLINEEND     = 13;
  308. CONST MUIKEYGADGETNEXT  = 14;
  309. CONST MUIKEYGADGETPREV  = 15;
  310. CONST MUIKEYGADGETOFF   = 16;
  311. CONST MUIKEYWINDOWCLOSE = 17;
  312. CONST MUIKEYWINDOWNEXT  = 18;
  313. CONST MUIKEYWINDOWPREV  = 19;
  314. CONST MUIKEYHELP        = 20;
  315. CONST MUIKEYPOPUP       = 21;
  316. CONST MUIKEYCOUNT       = 22; (* private *)
  317.  
  318. (*
  319. ** now something about dispatchers.
  320. ** if you have written your dispatcher make sure it has the format of
  321. ** PROCEDURE Dispatcher(cl : IClassPtr; obj : ADDRESS; msg : ADDRESS) : ADDRESS
  322. ** (like DispatcherDef)
  323. ** Then call in your main routine the procedure MakeDispatcher like this :
  324. ** MakeDispatcher(Dispatcher, MyClass),
  325. ** where MyClass is the initialized IClassPtr of your new class.
  326. ** This function will then set up your dispatcher with a little stub which
  327. ** will restore A4 for your (will mean, your programm will be pure, if you
  328. ** do all right)
  329. *)
  330.  
  331. (* here the definition of a dispatcher! *)
  332.  
  333. TYPE    DispatcherDef = PROCEDURE ( (*class*)   IClassPtr,
  334.                                     (*object*)  ADDRESS,
  335.                                     (*message*) ADDRESS) : ADDRESS;
  336.  
  337.  
  338.  
  339. (* now the procedure MakeDispatcher : *)
  340.  
  341. PROCEDURE MakeDispatcher(entry:DispatcherDef; VAR myclass : IClassPtr);
  342.  
  343.  
  344.  
  345. (* 
  346. ** at last a little procedure to fill in the values in the MinMax-Record.
  347. ** You can call it inside an AskMinMax-Method, because it is ever the same...
  348. *)
  349.  
  350. PROCEDURE FillMinMaxInfo (msg : mpAskMinMaxPtr; MinWidth   : CARDINAL;
  351.                                                 DefWidth   : CARDINAL;
  352.                                                 MaxWidth   : CARDINAL;
  353.                                                 MinHeight  : CARDINAL;
  354.                                                 DefHeight  : CARDINAL;
  355.                                                 MaxHeight  : CARDINAL);
  356.  
  357.  
  358. (*
  359. ** 2 useful procedures for testing if some coordinates are inside your object
  360. ** (converted from the ones in class3.c. So look there how to use... )
  361. *)
  362.  
  363. (* this will test if x is between a and b *)
  364.  
  365. PROCEDURE OBJ_between(a,x,b : INTEGER) : BOOLEAN;
  366.  
  367. (* this will test, if the position (x, y) is inside the Object obj *)
  368.  
  369. PROCEDURE OBJ_isInObject(x, y : INTEGER; obj : ObjectPtr) : BOOLEAN;
  370.  
  371.  
  372.  
  373. (* MUI_CustomClass returned by MUI_CreateCustomClass() *)                                    
  374.  
  375. TYPE
  376.     mCustomClass = RECORD
  377.                     userData            : APTR;         (* use for whatever you want *)
  378.                     utilityBase         : LibraryPtr;   (* MUI has opened these libraries *)
  379.                     dosBase             : LibraryPtr;   (* for you automatically. You can *)
  380.                     gfxBase             : LibraryPtr;   (* use them or decide to open     *)
  381.                     intuitionBase       : LibraryPtr;   (* your libraries yourself.       *)
  382.                                                                                              
  383.                     super               : IClassPtr;    (* pointer to super class   *)
  384.                     class               : IClassPtr;    (* pointer to the new class *)
  385.  
  386.                     (* ... private data follows ... *)
  387.  
  388.                   END;
  389.                                                                                              
  390.  
  391. END MuiClasses.
  392.